<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="root">

    </div>
    <button id="btnAdd">添加一个a 标签</button>
    <script>
        window.onload=function(){
            document.querySelector("#root").addEventListener("click",function(e){
                console.log("事件委托中currentTarget:",e.currentTarget)
                console.log("事件委托中current:",e.target)
                let target=e.target
                console.log(target)
                if(target.nodeName=="A"){
                    alert(target.innerHTML)
                }
            },true)
            document.querySelector("#btnAdd").addEventListener("click",function(e){
                console.log("currentTarget",e.currentTarget)
                console.log("target",e.target)
                let rootNode=document.querySelector("#root")
                rootNode.innerHTML+=`<a>${parseInt(Math.random()*10)}</a><br/>`
            },true)
        }
    </script>
</body>
</html>
